/*******************************************************
> Copyright (C) 2024 ==iot== All rights reserved.
> File Name: list.c
> Author: wyf
> Created Time: 2024年08月20日 星期二 13时05分55秒
***************************************************/
#include"list.h"


USE* List_init() {
	USE* p = malloc(sizeof(USE));
	memset(p, 0, sizeof(USE));
	p->Next = NULL;
	printf("\n");
	return p;
}

//打印输出的链表
void Printf_list(USE* head) {
	assert(head != NULL);
	USE* p = head->Next;
	while (p != NULL) {
		printf("id：%d 姓名: %s 密码: %s\n", p->user_id, p->user_name, p->user_password);
		p = p->Next;
	}
}

//释放链表
void freeLink(USE* head)
{
	assert(head != NULL);
	USE* temp = NULL;
	temp = head;
	USE* cur = NULL;
	while (temp != NULL)
	{
		cur = temp->Next;
		free(temp);
		temp = NULL;
		temp = cur;
	}
}


WP* List_init_WP() {
	WP* p = malloc(sizeof(WP));
	memset(p, 0, sizeof(WP));
	p->Next = NULL;
	printf("\n");
	return p;
}

//打印输出的链表
void Printf_list_WP(WP* head) {
	assert(head != NULL);
	WP* p = head->Next;
	while (p != NULL) {
		printf("id:%d\t名字:%s\n", p->id, p->pump_name);
		p = p->Next;
	}
}

//释放链表
void freeLink_WP(WP* head)
{
	assert(head != NULL);
	WP* temp = NULL;
	temp = head;
	WP* cur = NULL;
	while (temp != NULL)
	{
		cur = temp->Next;
		free(temp);
		temp = NULL;
		temp = cur;
	}
}


DAT* List_init_DAT() {
	DAT* p = malloc(sizeof(DAT));
	memset(p, 0, sizeof(DAT));
	p->Next = NULL;
	printf("\n");
	return p;
}

//打印输出的链表
void Printf_list_DAT(DAT* head) {
	assert(head != NULL);
	DAT* p = head->Next;
	while (p != NULL) {
		printf("%f,%f,%f,%d,%f,%f,%s,%d\n", p->temperature, p->liquid_level, p->flow_rate, p->valve_state, p->negative_pressure, p->pressure, p->time, p->pump_id);
		p = p->Next;
	}
}

//释放链表
void freeLink_DAT(DAT* head)
{
	assert(head != NULL);
	DAT* temp = NULL;
	temp = head;
	DAT* cur = NULL;
	while (temp != NULL)
	{
		cur = temp->Next;
		free(temp);
		temp = NULL;
		temp = cur;
	}
}